package jop_simulator;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;

public class MatrixDisplay extends JPanel {

    public int[][] Matrix = new int[0][0];

    public MatrixDisplay(){
        super();
    }

    @Override
    public void paintComponent(Graphics g) {
            super.paintComponent(g);

            Graphics2D g2d = (Graphics2D) g;

            Color White = new Color(255, 255, 255);
            Color Black = new Color(0,0,0);

            for(int i=0 ; i<Matrix.length ; i++)
                for(int j=0 ; j<Matrix[0].length ; j++){
                    //g2d.setColor(Matrix[i][j]==0 ? White : Black);
                    int toEncode = Matrix[i][j];
                    int a = toEncode % 2;
                    int b = (toEncode % 4)/2;
                    int c = (toEncode % 8)/4;
                    g2d.setColor(new Color(255*a,255*b,255*c));
                    g2d.fillRect(i*20, j*20, 20, 20);
                }
    }

    
}
